import re
camelcase_to_underscore = lambda str: re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', '_\\1', str).lower().strip('_')

def underscore_to_camelcase(str):
    r = []
    r.append(str[0].upper())
    nextupper = False
    for c in str[1:]:
        if c == "_":
            nextupper = True
        elif nextupper == True:
            r.append(c.upper())
            nextupper = False
        else:
            r.append(c)
    return ''.join(r)